package com.mcvcm.bpaint.model
{
	import flash.display.Sprite;
	import flash.geom.ColorTransform;
	
	// to extend class Sprite may affect the performance
	// but currently I have no better solution
	public class Bubble extends Sprite
	{
		private var _radius:uint;
		private var _color:uint;
		
		public function get radius ():uint
		{
			return _radius;
		}
		
		public function set radius (radius:uint):void
		{
			_radius = radius;
			scale();
		}
		
		public function get color ():uint
		{
			return _color;
		}
		
		public function set color (color:uint):void
		{
			_color = color;
			colorize();
		}
		
		public function Bubble ():void
		{
			draw();
		}
		
		private function draw ():void
		{
			with (graphics)
			{
				beginFill (0xaaaaaa);
				drawCircle (0, 0, 1);
				endFill ();
			}
		}
		
		private function scale ():void
		{
			scaleX = scaleY = _radius;
		}
		
		private function colorize ():void
		{
			var tmp:ColorTransform = transform.colorTransform;
			tmp.color = _color;
			transform.colorTransform = tmp;
		}
	}
}